package monitor;

import java.util.Date;

import jess.JessException;

import monitor.basic.Activity;
import monitor.basic.Monitor;
import monitor.inference.InferenceEngine;
import monitor.transmission.Transmitter;

import socio.Entity;
import socio.hardware.Basin;
import socio.initiative.Human;

public aspect BasinMonitor extends Monitor {

	public BasinMonitor() {
		super();
		try {
			InferenceEngine engine = new InferenceEngine(null, null);
			Transmitter transmitter = new Transmitter();
			this.setTransmitter(transmitter);
			this.setEngine(engine);
			this.start();
		} catch (JessException e) {
			e.printStackTrace();
		}
	}

	before(Basin basin, Human who, Entity what, Date when): 
		execution(void Basin.wash(Human,Entity,Date))
		&&target(basin)
		&&args(who,what,when) 
	{
		Activity activity = new Activity(who, "toWash", what, basin, when);
		this.recorder.record(activity);
		this.recorder.record("[" + when + "]" + who.getId()
				+ " is to wash vegetables");
	}

	after(Basin basin, Human who, Entity what, Date when) returning(): 
		execution(void Basin.wash(Human,Entity,Date))
		&&target(basin)
		&&args(who,what,when)
	{
		Activity activity = new Activity(who, "washed", what, basin, when);
		this.recorder.record(activity);
		this.recorder.record("[" + when + "]" + who.getId()
				+ " is has just washed vegetables");
	}
}
